<?php

defined('BY_JYA') or exit('error');
$cashierid=$this->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
if($_RQ['op']=='edit'){
	$return['item']=$this->plugin_setting('jy_cashier'.$cashierid);
	$return['status']=array('0'=>'关闭','1'=>'开启');
   
	$htmls=array(
		'type'=>'edit',
		'desc'=>'营销设置',
		'post'=>'post',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'随机立减',
				'list'=>array(
					array('name'=>'randtime','title'=>'随机立减活动时间','type'=>'time_range'),
					array('name'=>'limit','title'=>'最低支付金额','type'=>'string'),
					array('type'=>'array','name'=>'probability','title'=>'随机立减区间','add_tip'=>'添加一个随机立减区间',
					'list'=>array(
						array('title'=>'起','name'=>'start','type'=>'string'),	
						array('title'=>'终','name'=>'end','type'=>'string'),
						array('title'=>'概率','name'=>'jilv','type'=>'string'),						
					),
					'details'=>array(
						array('title'=>'起','name'=>'start','type'=>'string','help'=>'减免金额'),	
						array('title'=>'终','name'=>'end','type'=>'string'),
						array('title'=>'概率','name'=>'jilv','type'=>'string','help'=>'此处只需填写数字，各区间总数必须为100'),			
					)
					),
				)
			),
			array(
				'title'=>'满额立减',
				'list'=>array(
					array('name'=>'enoughtime','title'=>'满额立减活动时间','type'=>'time_range'),
					
					array('type'=>'array','name'=>'enough','title'=>'满额立减区间','add_tip'=>'添加一个随机立减区间',
					'list'=>array(
						array('title'=>'消费金额满','name'=>'money','type'=>'string'),	
						
						array('title'=>'减免金额','name'=>'jian','type'=>'string'),						
					),
					'details'=>array(
						array('title'=>'消费金额满','name'=>'money','type'=>'string'),	
						
						array('title'=>'减免金额','name'=>'jian','type'=>'string'),				
					)
					),
				)
			),
			array(
				'title'=>'固定折扣',
				'list'=>array(
					array('name'=>'discounttime','title'=>'固定折扣活动时间','type'=>'time_range'),
					array('name'=>'discount','title'=>'折扣','type'=>'unitstring','unit'=>'%','help'=>'比如填80，表示80%；'),		
			),
			),

		)
	);	
	$return['htmls']=$htmls;
	exi($return);
}

if($_RQ['op']=='post'){
	$post=get_postdata();		
	$this->plugin_setting('jy_cashier'.$cashierid,$post);
	exi('设置成功','');
}
